Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Iterating Through an Attribute Set

QuickDraw 3D provides the Q3AttributeSet_GetNextAttributeType function that you can use to iterate through the attributes in an attribute set. To get the first attribute in an attribute set, pass the constant kQ3AttributeTypeNone to Q3AttributeSet_GetNextAttributeType . You can retrieve any subsequent attributes by successively calling Q3AttributeSet_GetNextAttributeType , which returns kQ3AttributeTypeNone when you reach the end of the list of attributes. Listing 9 illustrates how to use Q3AttributeSet_GetNextAttributeType to determine the number of attributes in an attribute set.

Listing 9 Counting the attributes in an attribute set

unsigned long MyCountAttributesInSet (TQ3AttributeSet mySet)
{
    unsigned long                   myCount;        /*attribute count*/
    TQ3AttributeType                myType;         /*attribute type*/
    TQ3Status                       myResult;       /*result code*/

    for (myCount = 0,
          myType = kQ3AttributeTypeNone,
          myResult =
                Q3AttributeSet_GetNextAttributeType(mySet, &myType);
          myType != kQ3AttributeTypeNone;
          myResult =
            Q3AttributeSet_GetNextAttributeType(mySet, &myType)) {
        myCount++;
    }
    
    return (myCount);
}

Notice that the Q3AttributeSet_GetNextAttributeType function returns a result code that indicates whether the call succeeded or failed. In general, the call fails only if the attribute set is invalid in some way.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |